/**
 @file sys_usw_dmps_api.h

 @author  Copyright (C) 2022 Centec Networks Inc.  All rights reserved.

 @date 2022-10-25

 @version v1.0

*/

#ifndef _SYS_USW_DMPS_API_H
#define _SYS_USW_DMPS_API_H
#ifdef __cplusplus
extern "C" {
#endif

#include "sys_usw_dmps_reg.h"

struct sys_dmps_mac_api_db_s
{
    uint8  mac_grp_idx;
    uint8  mac_idx;
    uint8  pcs_grp_idx;
    uint8  pcs_idx;

    uint8  if_mode;
    uint8  fec_type;
    uint8  speed_mode;
    uint8  core_id;
    uint8  port_type;
    uint8  rsv;
};
typedef struct sys_dmps_mac_api_db_s sys_dmps_mac_api_db_t;

struct sys_dmps_api_cfg_s
{
    uint8  cfg_flag;    /* 1: need config; 0: no need config */
    uint32 cfg_value;
};
typedef struct sys_dmps_api_cfg_s sys_dmps_api_cfg_t;


#define SYS_DMPS_API_CFG_FIELD(p_api_cfg, p_fld_info, p_fld_num, p_idx, p_field_id)    \
do {\
    if (p_api_cfg.cfg_flag) \
    {   \
        SET_REG_FIELD_INFO(p_fld_info, p_fld_num, p_idx, p_field_id, p_api_cfg.cfg_value);  \
    }   \
} while(0)

#define SYS_DMPS_API_SET_FIELD_VALUE(p_api_cfg, p_value)    \
do {\
    p_api_cfg.cfg_flag = 1;\
    p_api_cfg.cfg_value = p_value;\
} while(0)

enum sys_usw_dmps_mac_api_e
{
    DMPS_MAC_API_SET_MAC_TX_EN,
    DMPS_MAC_API_SET_MAC_RX_EN,
    DMPS_MAC_API_SET_FEC,
    DMPS_MAC_API_SET_MODE,
    DMPS_MAC_API_SET_CL37_EN,
    DMPS_MAC_API_SET_CL37_MODE,
    DMPS_MAC_API_SET_CL73_EN,
    DMPS_MAC_API_SET_LINK_FILTER,
    DMPS_MAC_API_SET_FAULT_FILTER,
    DMPS_MAC_API_SET_IGNORE_FAULT,
    DMPS_MAC_API_SET_UNDIR_EN,
    DMPS_MAC_API_SET_LOOPBACK,
    DMPS_MAC_API_SET_TX_FORCE_FAULT,
    DMPS_MAC_API_SET_MII_RST,
    DMPS_MAC_API_SET_PCS_RST,
    DMPS_MAC_API_SET_FEC_RST,
    DMPS_MAC_API_SET_PKT_EN,
    DMPS_MAC_API_SET_FLOWCTL_ABILITY,
    DMPS_MAC_API_SET_IPG,
    DMPS_MAC_API_SET_PREAMBLE,
    DMPS_MAC_API_SET_PADDING_EN,
    DMPS_MAC_API_SET_CHECK_CRC_EN,
    DMPS_MAC_API_SET_STRIP_CRC_EN,
    DMPS_MAC_API_SET_APPEND_CRC_EN,
    DMPS_MAC_API_SET_APPEND_TOD_EN,
    DMPS_MAC_API_SET_TAILTS_EN,
    DMPS_MAC_API_SET_PARALLEL_DETECT_EN,
    DMPS_MAC_API_SET_SFD_EN,
    DMPS_MAC_API_SET_FAULT_MASK_LINK,
    DMPS_MAC_API_SET_FORCE_SIGDET,
    DMPS_MAC_API_SET_TX_PMAC_SFD_EN,
    DMPS_MAC_API_SET_RX_PMAC_SFD_EN,
    
    DMPS_MAC_API_GET_CL37_EN,
    DMPS_MAC_API_GET_CL37_MODE,
    DMPS_MAC_API_GET_LOOPBACK,
    DMPS_MAC_API_GET_TX_FORCE_FAULT,
    DMPS_MAC_API_GET_MII_RST,
    DMPS_MAC_API_GET_LINK_UP,
    DMPS_MAC_API_GET_PCS_STATUS,
    DMPS_MAC_API_GET_PCS_RST,
    DMPS_MAC_API_GET_PKT_EN,
    DMPS_MAC_API_GET_LINK_FILTER,
    DMPS_MAC_API_GET_FAULT_FILTER,
    DMPS_MAC_API_GET_LINK_FAULT,
    DMPS_MAC_API_GET_IGNORE_FAULT,
    DMPS_MAC_API_GET_UNDIR_EN,
    DMPS_MAC_API_GET_CL37_FLOWCTL_ABILITY_LOCAL,
    DMPS_MAC_API_GET_CL37_FLOWCTL_ABILITY_REMOTE,
    DMPS_MAC_API_GET_CL37_REMOTE_STATUS,
    DMPS_MAC_API_GET_IPG,
    DMPS_MAC_API_GET_PREAMBLE,
    DMPS_MAC_API_GET_PADDING_EN,
    DMPS_MAC_API_GET_CHECK_CRC_EN,
    DMPS_MAC_API_GET_STRIP_CRC_EN,
    DMPS_MAC_API_GET_APPEND_CRC_EN,
    DMPS_MAC_API_GET_APPEND_TOD_EN,
    DMPS_MAC_API_GET_TAILTS_EN,
    DMPS_MAC_API_GET_PARALLEL_DETECT_EN,
    DMPS_MAC_API_GET_SFD_EN,
    DMPS_MAC_API_GET_FORCE_SIGDET,
    DMPS_MAC_API_GET_TX_PMAC_SFD_EN,
    DMPS_MAC_API_GET_RX_PMAC_SFD_EN,
    DMPS_MAC_API_GET_CODE_ERR,
    DMPS_MAC_API_GET_FEC_CNT,

    DMPS_MAC_API_MAX,
};

typedef enum sys_usw_dmps_mac_api_e sys_usw_dmps_mac_api_t;

enum sys_usw_dmps_mac_module_e
{
    DMPS_MAC_MODULE_SHARED,

    DMPS_MAC_MODULE_MAX,
};
typedef enum sys_usw_dmps_mac_module_e sys_usw_dmps_mac_module_t;


#define DMPS_MAC_API(p_mac_module, p_api, ...) do\
{\
    switch (p_mac_module)\
    {\
        case DMPS_MAC_MODULE_SHARED:\
            CTC_ERROR_RETURN(DMPS_SHARED_API(p_api, ##__VA_ARGS__));\
            break;\
        default:\
            break;\
    }\
} while (0)



#ifdef __cplusplus
}
#endif

#endif

